<%@ include file="/taglibs.jsp" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<head>
	<title>北京邮电大学学生党员在线学习中心</title>
	
	<link type="text/css" rel="stylesheet" href="${ctx}/css/jquery-ui-1.8.16.custom.css" />
	
	<script type="text/javascript" src="${ctx}/scripts/jquery-1.6.2.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/jquery-ui-1.8.16.custom.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/jquery.ui.core.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/jquery.ui.datepicker.js"></script>
	
	<script type="text/javascript">
        
	   var xmlHttp;
	  
		 function changeSecond(value) {
	       if(value != -1) {
               var uri = "AdminAction_getChildrenPaByParentId?parentId=" + escape(value);
               if(window.XMLHttpRequest) {
                   xmlHttp = new XMLHttpRequest();
               } else {
                   try {
                       xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                   } catch(e) {
                       try {
                           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                       } catch(e) {
                           alert("不能创建XMLHttpRequest对象!!!");
                           return;
                   }
               }
           }
                xmlHttp.open("post", uri, true);
                xmlHttp.onreadystatechange = handleResponse;
                xmlHttp.send(null);
       } else {
    	    clearElement1("secondPa");
       }
     }
		 
		  function handleResponse() {
           if(xmlHttp.readyState == 4) {
               if(xmlHttp.status == 200) {
                   updateSelect("secondPa");
                   var idList = xmlHttp.responseXML.getElementsByTagName("id"); 
                   if(idList.length < 1) {
                	   clearElement1("secondPa");
                   } else {
                	   ;
                   }
               }
           }
       }
		  
		  
	  //根据返回的结果更新党支部信息
		function  updateSelect(id) {
			var selectList = document.getElementById(id);
			var idList = xmlHttp.responseXML.getElementsByTagName("id");
			var nameList = xmlHttp.responseXML.getElementsByTagName("branchName");
			if(idList.length > 0) {
				document.getElementById(id).style.display="inline";
				clearElement(id);
				selectList.options.add(new Option('请选择党支部', '-1'));
				for(var i = 0; i<idList.length; i++) {
					selectList.options.add(new Option(nameList[i].firstChild.nodeValue, idList[i].firstChild.nodeValue));
				}
			}
			else{
				document.getElementById(id).style.display="none";
			}
			
		}
		
		 //清除元素
		function clearElement(id) {
			document.getElementById(id).length = 0;
		}
		 
		//当只有一级或者两级党组织时，需要清理遗留的其他党组织信息
		function clearElement1(id) {
		   var selectList = document.getElementById(id);
    	   clearElement(id);
    	   selectList.options.add(new Option('请选择党支部', '-1'));
    	   document.getElementById(id).style.display="none";
		 }
	
	</script> 
	
		
	
	
	<!--验证身份证开始 -->
	<script type="text/javascript">
	var vcity={ 11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",
	               21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",
	               33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",
	               42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",
	               51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",
	               63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
	
	 function checkCard(card)
	   {
		   
	        var isum=0;
	        var re=/^\d{17}(\d|X)$/i;
			var cardidstr=card;
	      
	        if (cardidstr.length>0 && cardidstr!=null)
	        {
	            if(!re.test(cardidstr))
	            {
	               
	                return 0;
	            }
	
				if(vcity[parseInt(cardidstr.substr(0,2))]==null)
	            {
	               
	                return 1;
	            }
				
				
				
	
	  //检查出生日期是否合 法
	            sbirthday=cardidstr.substr(6,4)+"-"+Number(cardidstr.substr(10,2))+"-" + Number(cardidstr.substr(12,2));
	            var date=new Date(sbirthday.replace(/-/g,"/"));
				
				 var x=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
	           if(sbirthday!=x){
	                
	                return 2;
	           }
				
	
	 //检查验证码是否合法
	            for(var i=17;i>=0;i--){
	            
	                isum+=(Math.pow(2,i)%11)*parseInt(cardidstr.charAt(17-i),11);
	            }
	            if(isum%11!=1){
	                
	                return 3;
	            }
	            
	           
	        }
	  else
	        {//请输入身份证
	           
	            return 4;
	        }    
	   }

	</script>
	
	<!--验证身份证结束 -->
	
	
	
	
	<script type="text/javascript">
	String.prototype.trim = function()
	{
	  return this.replace(/(^\s*)|(\s*$)/g, "");
	}
	
	function check() {
		   
		
		   var studentName = document.form1.studentName.value.toString();//姓名*
		   var studentSfzNO = document.form1.studentSfzNO.value.toString();//身份证号*
		   var studentGender = document.form1.studentGender.value.toString();//性别*
		   var studentNationality = document.form1.studentNationality.value.toString();//民族
		   var firstPa = document.form1.firstPa.value.toString();//党委*
		   var secondPa = document.form1.secondPa.value.toString();//党支部*
		   var studentTelephone = document.form1.studentTelephone.value.toString();//电话号码
		   var studentEmail = document.form1.studentEmail.value.toString(); //邮箱
		   
		   var result= checkCard(studentSfzNO);
		   
		  if(studentName == 0) { 
		       alert('姓名不能为空 ！');
		       document.form1.studentName.focus();
		       return false;
		        
	  	  }else if(studentName.length>60){
			   alert('姓名字符长度不能超过60!');
		       document.form1.studentName.focus();
		       return false;
		   }else if(result==0){
				 alert("身份证不符合要求!");
				 return false;
			}else if(result==1){
				 alert("身份地址不符合要求!");
				 return false;
			}else if(result==2){
				alert("身份证出生日期非法!");
				 return false;
			}else if(result==3){
				alert("身份证号码校验错误!");
				 return false;
			}else if(result==4){
				 alert("请输入身份证号!");
				 return false;
			}else if(studentGender == 0) {
			       alert('请选择性别！');
			       document.form1.studentGender.focus();
			       return false;
			        
		   }else if(studentNationality==0) {
		       alert('请选择民族!');
		       document.form1.studentNationality.focus();
		       return false;
		       
		   }else if(firstPa== -1) { 
		       alert('请选择党委 !');
		       document.form1.firstPa.focus();
		       return false;
		       
		   } else if(secondPa==-1) {
		       alert('请选择支部!');
		       document.form1.secondPa.focus();
		       return false;
		       
		   }else if(studentTelephone.length>60){
			   alert('电话号码字符长度不能超过60!');
		       document.form1.studentTelephone.focus();
		       return false;
		   }else if(studentEmail.length>60){
			   alert('电子邮箱字符长度不能超过60!');
		       document.form1.studentEmail.focus();
		       return false;
		   }   
	
		}
				
	
	</script>
	
</head>
<div id="nav_bar">
    <img id="nav_bar_left" src="../../../styles/nav_bar_left.png" alt=""/>
    <div id="welcome_label">欢迎您，&nbsp;<s:property value="#session.session_user.adminName" />!</div>
    <img id="nav_bar_seperator" src="../../../styles/nav_bar_seperator.png" alt=""/>
    <div id="nav_location">
        <img id="nav_bar_point" src="../../../styles/nav_bar_point.png" alt="" />
        <div id="nav_cur_location">当前位置：&nbsp;<a href="${ctx}/AdminAction_manageUser" >用户管理</a>&nbsp;&nbsp;>&nbsp;&nbsp;<a href="AdminAction_memberList">成员信息维护</a>&nbsp;&nbsp;>&nbsp;&nbsp;修改学生信息</div>
    </div>
    <img style="float:right; width:5px;" src="../../../styles/nav_bar_right.png" alt=""/>
    <a id="nav_logout" href="${ctx}/logoutAction_adminLogout">[安全退出]</a>
</div>
<div style="clear:both; height:5px;">&nbsp;</div>

<div style="min-height:450px;">
	<div id="side_menu">
	    <div id="side_menu_title">
	        <img src="../../../styles/side_menu_title_img.png" alt="" />
	        <span>用户管理</span>
	    </div>
	    <div id="side_menu_title_bottom">&nbsp;</div>
	    <div class="side_sub_menu_focus">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="AdminAction_memberList">成员信息维护</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="AdminAction_addStudent">新增学生用户</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="AdminAction_resetUserPassword">用户密码重置</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <s:if test="#session.level == 2 || #session.level == 3">
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="AdminAction_addAdministrator">新增管理员用户</a>
	    </div>
	    <div class="side_menu_seperator">&nbsp;</div>
	    <div class="side_sub_menu">
	        <div class="side_menu_point">&nbsp;</div>
	        <a href="AdminAction_adminList">管理员信息维护</a>
	    </div>
	    </s:if>
	</div>
	
	<div id="main_content">
	    <div id="main_content_title">
	        <img src="../../../styles/content_title_img.png" alt="" />
	        <span>修改学生信息</span>
	    </div>
	    <div class="main_content_title_bottom">&nbsp;</div>


			<s:form action="AdminAction_save_modifyStudentInfo" name="form1"  method="post" onsubmit="return check();"  theme="simple">
			
			<input id="highLevelQuery" name="highLevelQuery" type="hidden"  value='<s:property value="#request.highLevelQuery"/>' />
			<input id="queryContent" name="queryContent" type="hidden"  value='<s:property value="#request.queryContent"/>' />
			<input id="firstPaHidden" name="firstPaHidden" type="hidden"  value='<s:property value="#request.firstPaHidden"/>' />
			<input id="secondPaHidden" name="secondPaHidden" type="hidden"  value='<s:property value="#request.secondPaHidden"/>' />
			<input id="pageNow" name="pageNow" type="hidden"  value='<s:property value="#request.pageNow"/>' />
			
			<table id="table" class="page_table" cellspacing="0" cellpadding="0" >
			<tr>
				<td class="leftTD">姓名:</td>
				<td class="rightTD">
					<input id="studentName" name="studentName" type="text" value='<s:property value="#request.student.studentName"/>'  />
					<font color="red">*</font>
				</td>
				
			</tr>
			<tr>
				<td class="leftTD2">学号:</td>
				<td><s:property value="#request.student.studentNo"/>
				<input id="studentNO" name="studentNO" type="hidden"  value='<s:property value="#request.student.studentNo"/>' />
				</td>
			</tr>
			<tr>
				<td class="leftTD">身份证号:</td>
				<td class="rightTD2">
					<input id="studentSfzNO" name="studentSfzNO" type="text" value='<s:property value="#request.student.studentIdentity"/>'/>
			    	<font color="red">*</font>
			    </td>
				
			</tr>
			<tr>
				<td class="leftTD2">性别:</td>
				<td class="rightTD">
					<select id="studentGender" name="studentGender" style="width:40%;">
						<s:if test="#request.student.studentGender == 1">
							 <option value="0" >请选择</option>
							 <option value="1" selected="selected">男</option>
							 <option value="2" >女</option>
						</s:if>
						<s:else>
							<option value="0" >请选择</option>
							<option value="1" >男</option>
							<option value="2" selected="selected">女</option>
						</s:else>
					</select><font color="red">*</font>	
				</td>
			</tr>
			<tr>
				<td class="leftTD">民族:</td>
			    <td>
			       <select id="studentNationality" name="studentNationality" style="width:40%;">
						<s:iterator value="nationality.collection">
						   <s:if test="id == #request.student.studentNationality">
						   <option value="<s:property value='id' />" selected="selected"><s:property value='name' /></option>
						   </s:if>
							<s:else>
							  <option value="<s:property value='id' />" ><s:property value='name'/></option>
							</s:else>
						</s:iterator>
					</select>
				</td>
			</tr>
			<tr>
				<td class="leftTD2">所属党组织:</td>
				<td class="rightTD2">
					<s:select id="firstPa" list="firstPaList" listKey="id" listValue="branchName" name="firstPa" headerKey="-1" headerValue="请选择党委"  onchange="changeSecond(this.value);" value="#request.firstPa" style="width:40%;"/>
					
						<s:select id="secondPa" list="secondPaList" listKey="id" listValue="branchName" name="secondPa" headerKey="-1" headerValue="请选择支部"  value="#request.secondPa"style="width:55%;"/>
					
			        <font color=red>*</font>
				</td>
			</tr>
			<tr>
				<td class="leftTD">联系电话:</td>
				<td class="rightTD"><input id="studentTelephone" name="studentTelephone" type="text" value='<s:property value="#request.student.studentTelephone"/>'/></td>
			</tr>
			<tr>
				<td class="leftTD2">电子邮箱:</td>
				<td class="rightTD"><input id="studentEmail" name="studentEmail" type="text" value='<s:property value="#request.student.studentEmail"/>'/></td>
			</tr>
			</table>
			
			
			<div style="clear:both; height:5px;"></div>
			<div style="text-align:center; width:90%;">
				<input type="submit"  name="submit" id="submit" class="input-button" value="保存" />
				<input id="history" name="history" type="button" class="input-button" value="返回" onclick="window.location.href='javascript:history.go(-1);'"/>
			</div>
			</s:form>
		</div>
</div>
